home *** CD-ROM | disk | FTP | other *** search
- Path: pegasus.odyssee.net!news
- From: imaze@odyssee.net (Marc Mazerolle)
- Newsgroups: comp.lang.c++
- Subject: Re: what happens w/delete called twice ?
- Date: Sun, 25 Feb 1996 05:17:27 GMT
- Organization: Odyssee Internet
- Message-ID: <4goqk0$jul@pegasus.odyssee.net>
- References: <kcc.423.0EE12CF6@interaccess.com>
- Reply-To: imaze@odyssee.net
- NNTP-Posting-Host: pool21_10.odyssee.net
- X-Newsreader: Forte Free Agent v0.55
-
- kcc@interaccess.com (kcc) wrote:
-
- >Hello,
-
- > Can someone tell me... what happens when delete is called twice for the same
- >memory deallocation ie.,
-
- > SOME_STRUCT *struct_p = new SOME STRUCT;
-
- > if ( foo_a() )
- > {
- > delete struct_p;
- > retvalue = 0;
- > }
- > else
- > {
- > retvalue = foo_b();
- > }
-
- > delete struct_p;
-
- > return( retvalue );
-
-
-
- >Thanx !
- >kcc
-
- Most compilers won't produce any error since their delete function
- will nullify your pointer and deleting a null pointer is also
- supported by most compiler.
-
- But, if you wan't to write portable code, i suggest you don't do it.
-
-